<template>  <div class="stat-card theme-purple">
    <div class="time-card-header">
      <span class="stat-title">{{ timeCardTitle }}</span>      <button class="ai-analysis-btn" @click="goToAIAnalysis" title="查看AI学习分析">
        🧠 AI分析
      </button>
    </div>
    <div class="time-stat">
      <span class="time-value">{{ todayTime }}</span>
      <span class="time-unit">min</span>
    </div>
    <div class="chart-container" v-if="showChart">
      <WordDataLine :data="lineChartData" />
    </div>
    <LearningTimeStats
      :yesterdayTime="yesterdayTime"
      :weeklyTime="weeklyTime"
    />
  </div>
</template>

<script>
import LearningTimeStats from "./LearningTimeStats.vue";
import WordDataLine from "../WordDataLine.vue";

export default {
  name: "LearningStatistics",
  components: {
    LearningTimeStats,
    WordDataLine,
  },
  props: {
    timeCardTitle: {
      type: String,
      default: "今日学习时长"
    },
    todayTime: {
      type: [Number, String],
      default: 0
    },
    yesterdayTime: {
      type: [Number, String],
      default: 0
    },
    weeklyTime: {
      type: [Number, String],
      default: 0
    },
    lineChartData: {
      type: Array,
      default: () => []
    },
    showChart: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    goToAIAnalysis() {
      this.$router.push('/ai-analysis');
    }
  }
};
</script>

<style scoped>
.stat-card {
  height: auto;
  min-height: 279px;
  margin: 0;
  width: 100%;
  max-width: 440px;
  min-width: 300px;
  flex: 1;
  color: white;
}

.time-card-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-analysis-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.ai-analysis-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.chart-container {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 15px 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px;
}

@media (max-width: 707px) {
  .stat-card {
    width: 100%;
    margin: 0;
    align-self: center;
    max-width: none;
    min-height: 231px;
    min-width: unset;
  }
}
</style>
